package com.precisosoft.mathematize.client.gin;



import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import com.google.inject.Singleton;
import com.gwtplatform.dispatch.shared.SecurityCookie;
import com.gwtplatform.mvp.client.RootPresenter;
import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
import com.gwtplatform.mvp.client.proxy.ParameterTokenFormatter;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.TokenFormatter;
import com.precisosoft.mathematize.client.LoggedInGatekeeper;
import com.precisosoft.mathematize.client.MathematizePlaceManager;
import com.precisosoft.mathematize.client.NameTokens;
import com.precisosoft.mathematize.client.presenter.ErrorPagePresenter;
import com.precisosoft.mathematize.client.presenter.HomePagePresenter;
import com.precisosoft.mathematize.client.presenter.MainPagePresenter;
import com.precisosoft.mathematize.client.presenter.SignInPagePresenter;
import com.precisosoft.mathematize.client.view.ErrorPageView;
import com.precisosoft.mathematize.client.view.HomePageView;
import com.precisosoft.mathematize.client.view.MainPageView;
import com.precisosoft.mathematize.client.view.SignInPageView;
import com.precisosoft.mathematize.shared.SharedTokens;

public class ClientModule extends AbstractPresenterModule {

	  @Override
	  protected void configure() {

		    // Protect against XSRF attacks - securityCookieName = "JSESSIONID";
		    bindConstant().annotatedWith(SecurityCookie.class).to(SharedTokens.securityCookieName);

		    // Singletons
		    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
		    bind(PlaceManager.class).to(MathematizePlaceManager.class).in(Singleton.class);
		    bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
		    bind(RootPresenter.class).asEagerSingleton();
//		    bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);
		    
		    // bind(Resources.class).in(Singleton.class);
		    // bind(Translations.class).in(Singleton.class);
		    // bind(CurrentUser.class).asEagerSingleton();  
		    
		    bind(LoggedInGatekeeper.class).in(Singleton.class);
		    //bind(AdminGatekeeper.class).in(Singleton.class);

		    // Constants
		    // Bind the Sign In page to the default place
		    bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.homePage);

		    // Presenters

		    // Sign In
		    bindPresenter(SignInPagePresenter.class, SignInPagePresenter.MyView.class,
		        SignInPageView.class, SignInPagePresenter.MyProxy.class);

		    // Main Pages
		    bindPresenter(HomePagePresenter.class, HomePagePresenter.MyView.class,
			        HomePageView.class, HomePagePresenter.MyProxy.class);
		    bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class,
			        MainPageView.class, MainPagePresenter.MyProxy.class);
//		    bindPresenter(AccountPagePresenter.class, AccountPagePresenter.MyView.class,
//		        AccountPageView.class, AccountPagePresenter.MyProxy.class);
//		    bindPresenter(FileUploadPagePresenter.class, FileUploadPagePresenter.MyView.class,
//		        FileUploadPageView.class, FileUploadPagePresenter.MyProxy.class);

		    // Error Page
		    bindPresenter(ErrorPagePresenter.class, ErrorPagePresenter.MyView.class,
		        ErrorPageView.class, ErrorPagePresenter.MyProxy.class);

		    // Sales
//		    bindPresenter(ActivitiesPresenter.class, ActivitiesPresenter.MyView.class,
//		        ActivitiesView.class, ActivitiesPresenter.MyProxy.class);
//		    bindPresenter(CalendarPresenter.class, CalendarPresenter.MyView.class,
//		        CalendarView.class, CalendarPresenter.MyProxy.class);
//		    bindPresenter(DashboardsPresenter.class, DashboardsPresenter.MyView.class,
//		        DashboardsView.class, DashboardsPresenter.MyProxy.class);
//		    bindPresenter(ImportsPresenter.class, ImportsPresenter.MyView.class,
//		        ImportsView.class, ImportsPresenter.MyProxy.class);
//		    bindPresenter(AccountsPresenter.class, AccountsPresenter.MyView.class,
//		        AccountsView.class, AccountsPresenter.MyProxy.class);
//		    bindPresenter(ReportsPresenter.class, ReportsPresenter.MyView.class,
//		        ReportsView.class, ReportsPresenter.MyProxy.class);
//
//
//		    bindPresenter(AccountInformationPresenter.class, AccountInformationPresenter.MyView.class,
//		        AccountInformationView.class, AccountInformationPresenter.MyProxy.class);
//
		    // Settings
//		    bindPresenter(AdministrationPresenter.class, AdministrationPresenter.MyView.class,
//		        AdministrationView.class, AdministrationPresenter.MyProxy.class);
//
//		    // Resource Centre
//		    bindPresenter(HighlightsPresenter.class, HighlightsPresenter.MyView.class,
//		        HighlightsView.class, HighlightsPresenter.MyProxy.class);
	    
	  }

}
